Page({
    data: {
      pop:false,
      params: {
        page: 1,
        size: 10,
        userIds: wx.getStorageSync('userId')
      },
      list: []
    },

  //来货提醒
  openPop () {
    this.setData({
      pop: true
    })
  },

  goTixing () {
    wx.requestSubscribeMessage({
      tmplIds: ["gg3x6wtwo3OiPR0due-tLevMZMONJtltVzEWUCKwvzk"],
      success: (res) => {

        if (res['gg3x6wtwo3OiPR0due-tLevMZMONJtltVzEWUCKwvzk'] === 'accept') {
          wx.showToast({
            title: '授权成功',
            icon: 'none'
          })

        }

      },
      fail(err) {
        //失败
        console.error(err);
        // reject()
      }
    })
  },


  bookdetail(e) {
    console.log(e)


    if (wx.getStorageSync('token') == '') {
      this.setData({
        istokenPop: true
      })
      return
    }

    var bookId = e.currentTarget.dataset.bookid
    wx.navigateTo({
      url: '/package/index/pages/bookdetail/bookdetail?bookId=' + bookId,
    })
  },

  //关闭弹窗
  closePop () {
    this.setData({
      pop: false
    })
  },

  //复制功能
  copy () {
    wx.setClipboardData({
      data: "书濑熊",
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            wx.showToast({
              title: '复制成功',
              icon: 'none'
            })
          }
        })
      }
    })
  },
  // 接口部分

  // 获取心愿单列表
  getList (params) {
    var _this = this
    wx.request({
      url: 'https://devapi.xiaoshitimebank.com/user/sdx/sdx/sdxWishList/find/auth',
      data: params,
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
      "token" : wx.getStorageSync('token'),
        "uid" : wx.getStorageSync('uuid')
      },
      success: (res) => {
        console.log(res)
        if (res.data.code == 200) {
          _this.setData({
            total: res.data.count
          })
          var list = _this.data.list

          res.data.data.forEach(function (item,index) {
            list.push(item)
          })

          _this.setData({
            list: list
          })
        }else{
          wx.showToast({
            title: res.data.msg,
            icon: 'none'
          })
        }
      }
    })
  },

  onShow () {
    this.setData({
      list: [],
      params: {
        page: 1,
        size: 10,
        userIds: wx.getStorageSync('userId')
      }
    })
    this.getList(this.data.params)
  }
})
